//$(function(){
////判断登录
//var login_btn = $("#yonghuming");
//var register_btn = $("#tuichu");
//
//if(getCookie("true")=="true"){
//	login_btn.text("您好！"+getCookie("user"));
//	//login_btn.attr("href","javascript:;");
//	register_btn.text("退出").css("color","#EE0011");
//	register_btn.attr("href","javascript:;");	
//}else{
//	login_btn.text("登录").css("color","#EE0011").attr("href","denglu.html");
//	register_btn.text("注册").css("color","#EE0011").attr("href","zhuce.html");	
//}
//if(register_btn.text()=="退出"){
//	register_btn.click(function(){
//	setCookie("true",false,setCookieDate(7),"/");
//	login_btn.text("登录").css("color","#EE0011").attr("href","javascript:;");
//	register_btn.text("注册").css("color","#EE0011").attr("href","javascript:;");
//	login_btn.click(function(){
//		window.location.href = "denglu.html";
//	});
//	register_btn.click(function(){
//		window.location.href = "zhuce.html";
//	})
//}

})

//正则
$("#content .nei .shdz div.tianxie .topdz .xuangxiang input.yi").focus(function(){
	$(this).val("");
})
$("#content .nei .shdz div.tianxie .topdz .xuangxiang input.yi").blur(function(){
	var reg1 = /^[\u4e00-\u9fa5]{2,4}$/;
	var str = $(this).val();
	if(str == ""){
		$(this).val("请输入！");
	}else if(reg1.test(str)){
		alert("有效！")
	}else{
		$(this).val("输入有误！");
		
	}
})
$("#content .nei .shdz div.tianxie .topdz .xuangxiang input.er").focus(function(){
	$(this).val("");
})
$("#content .nei .shdz div.tianxie .topdz .xuangxiang input.er").blur(function(){
	var reg1 = /^\d{11}$/;
	var str = $(this).val();
	if(str == ""){
		$(this).val("请输入！");
	}else if(reg1.test(str)){
		alert("有效！")
	}else{
		$(this).val("输入有误！");
		
	}
})
$("#content .nei .shdz div.tianxie .topdz .xuangxiang input.san").focus(function(){
	$(this).val("");
})
$("#content .nei .shdz div.tianxie .topdz .xuangxiang input.san").blur(function(){
	var reg1 = "010";
	var str = $(this).val();
	if(str == ""){
		$(this).val("请输入！");
	}else if(str == 010){
		alert("有效！")
	}else{
		$(this).val("输入有误！");
		
	}
})
$("#content .nei .shdz div.tianxie .topdz .xuangxiang input.si").focus(function(){
	$(this).val("");
})
$("#content .nei .shdz div.tianxie .topdz .xuangxiang input.si").blur(function(){
	var reg1 = /^\d{8}$/;
	var str = $(this).val();
	if(str == ""){
		$(this).val("请输入！");
	}else if(reg1.test(str)){
		alert("有效！")
	}else{
		$(this).val("输入有误！");
		
	}
})

$("#content .nei .shdz div.tianxie .topdz .xuangxiang input.liu").focus(function(){
	$(this).val("");
})
$("#content .nei .shdz div.tianxie .topdz .xuangxiang input.liu").blur(function(){
	var reg1 = /^[\u4e00-\u9fa5]+$/;
	var str = $(this).val();
	if(str == ""){
		$(this).val("请输入！");
	}else if(reg1.test(str)){
		alert("有效！")
	}else{
		$(this).val("输入有误！");
		
	}
})
$("#content .nei .shdz div.tianxie .topdz .xuangxiang input.qi").focus(function(){
	$(this).val("");
})
$("#content .nei .shdz div.tianxie .topdz .xuangxiang input.qi").blur(function(){
	var reg1 = /^\d{6}$/;
	var str = $(this).val();
	if(str == ""){
		$(this).val("请输入！");
	}else if(reg1.test(str)){
		alert("有效！")
	}else{
		$(this).val("输入有误！");
		
	}
})
//确认地址
$("#content .nei .shdz #qrdzbtn").click(function(){
	$(this).parent().children("h3").show().siblings().hide();
	$(this).parent().css("height","40px");
})


$("#content .nei .shdz h3").click(function(){
	$(this).parent().children().show();
	$(this).parent().css("height","502px");
})
//添加内容
				var cookies = document.cookie;

				var cook = cookies.split("; ");
				var arr = [];
				for (var i = 0 ; i < cook.length; i++){
					var daid = cook[i].split("=");
					var nameid = daid[0];
					
					if(nameid[nameid.length-1] == "b" ){
						arr.push(daid[1]);
					}
					
				}
				//alert(arr);
				$.ajax({
					url:"../json/list.json",
					dataType:"json",
					async:false,
					success:function(data){
						var mag = data.data;
						var str = "";
						var num = 0;
						for(var i = 0; i < arr.length;i++){
							for(var j = 0; j < mag.length;j++){
								if(arr[i] == mag[j].id){
									//alert(1);
									str += '<div class="tjspson"><div class="l one">21-061-1070</div><div class="l two"><img src="../img/list/'+getCookie(arr[i])+'.jpg" class="l" /><a class=" xinghao">'+mag[j].atext+'</a><p>颜色: <span class="color">'+getCookie(arr[i]+"c")+'</span> 尺码: <span class="size">'+getCookie(arr[i]+"s")+'</span></p></div><div class="l three" id="hdjf">'+(Number(mag[j].price)+30)*getCookie(arr[i]+"n")+'</div><div class="l four" id="shuliang">'+getCookie(arr[i]+"n")+'</div><div class="l five" id="danjia">'+mag[j].price+'</div><div class="l six" id="xiaoji">'+(getCookie(arr[i]+"n")*mag[j].price)+'</div></div>';
								num += Number(getCookie(arr[i]+"n"));
								}
								$("#tjspcon").html(str);
							}
						}
						$("#content .nei .tjdd .tjddtop .sp p.spjs #jianshu").html(num);
						$("#content .nei .tjdd .tjddtop .sp p.qita #jsje").html(num*30);
						$("#content .nei .tjdd .tjddtop .sp p.qita #spzj").html(getCookie("firstmoney"));
						$("#content .nei .tjdd .tjddtop .sp p.xzfje #xzfje").html(getCookie("firstmoney"));
						$("#content .nei .zhifubao .bottomzfb #zhifuprice").html(getCookie("firstmoney"));
					}
				});



//返回购物车
$(".fhgwc").click(function(){
	if(confirm("是要放弃支付直接返回购物车吗？亲！")){
		qingchudingdan();
		window.location.href="shopcar.html";	
	}
	
})
$("#content .nei .tjdd .tjddbottom #tjddbtn").click(function(){
	window.location.href="querenzhifu.html"
})




function qingchudingdan(){
	var cookies = document.cookie;
	var cook = cookies.split("; ");
	for (var i = 0 ; i < cook.length; i++){
		var daid = cook[i].split("=");
		var nameid = daid[0];
		
		if(nameid[nameid.length-1] == "b" ){
			removeCookie(daid[0]);
		}
	}
}




})
